home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
United Public Domain Gold 2
/
United Public Domain Gold 2.iso
/
education
/
pe023.dms
/
pe023.adf
/
ALGORHYTHMS
/
SOURCE
/
GADGETS.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-10-05
|
18KB
|
634 lines
/* gadgets.c */
/* Copyright 1990 Thomas E. Janzen All Rights Reserved */
/*
** FACILITY:
**
** AlgoRhythms music improviser on Commodore (TM) Amiga (TM)
** compiled with Lattice (TM) C 5.05
**
** ABSTRACT:
**
** Algorhythms improvises music over the MIDI serial port.
**
** AUTHORS: Thomas E. Janzen
**
** CREATION DATE: 26-MAR-1990
**
** MODIFICATION HISTORY:
** DATE NAME DESCRIPTION
**--
*/
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <intuition/intuition.h>
#include <graphics/text.h>
#include <proto/dos.h>
#include <proto/graphics.h>
#include <proto/exec.h>
#include <proto/mathffp.h>
#include <proto/intuition.h>
#define STRINGSIZE 80
/*WINDOW*/
extern struct Window *w;
/* GADGET */
#define GADGETTEXTDOWN (12)
#define CLEFT (10)
#define CTOP (6)
#define GADGETWIDTH (300)
#define GADGETHEIGHT (24)
#define LEFTEDGE (-1)
#define TOPEDGE (-1)
#define REQUESTERTEXTDOWN (34)
#define REQUESTERWIDTH (350)
#define REQUESTERHEIGHT (47)
/*for last routine*/
#define GADGETWIDE 230
#define GADGETHIGH 10
#define TOP 1
#define LEFT 100
extern struct GfxBase *GfxBase;
extern struct IntuitionBase *IntuitionBase;
extern struct DOSBase *DOSBase;
extern struct MathBase *MathBase;
char *MIDItoPitchName(int NoteNum, char *PitchName);
int PitchNametoMIDI(char *PitchName);
char *GetGadgetInput(
char Previous[],
char RemindString[],
char PromptString[]) {
register int classb;
static char GadgetString[32];
static struct IntuiText GadgetTxt=
{1,2,JAM2,10,GADGETTEXTDOWN,NULL,NULL,NULL};
static struct StringInfo
StringStuff={NULL,NULL,0,STRINGSIZE,0,0,0,0,
CLEFT,CTOP,NULL,0,NULL};
SHORT GadgetPairs[]=
{0,0,GADGETWIDTH,0,GADGETWIDTH,GADGETHEIGHT,0,
GADGETHEIGHT,0,0};
struct Border GadgetBorder=
{LEFTEDGE,TOPEDGE,1,2,JAM1,5,NULL,NULL};
static struct Gadget StringBox = {
NULL,2,6,GADGETWIDTH,GADGETHEIGHT,
GADGHCOMP,RELVERIFY|STRINGCENTER,
STRGADGET|REQGADGET,
NULL,NULL,NULL,0L,NULL,1,NULL};
/*REQUESTER*/
static UBYTE RequestString[32];
static struct IntuiText RequestTxt={1,2,JAM2,10,REQUESTERTEXTDOWN,
NULL,RequestString,NULL};
static SHORT RequesterPairs[]={0,0,REQUESTERWIDTH-1,0,
REQUESTERWIDTH-1,REQUESTERHEIGHT-1,0,REQUESTERHEIGHT-1,0,0};
static struct Border RequesterBorder={0,0,1,0,JAM1,5,NULL,NULL};
struct Requester AnswerRequest;
struct IntuiMessage *message;
BOOL Waiton=TRUE;
InitRequester(&AnswerRequest);
strcpy(RequestString,RemindString);
strcpy(GadgetString,PromptString);
AnswerRequest.OlderRequest=NULL;
AnswerRequest.LeftEdge=10; /*position*/
AnswerRequest.TopEdge=30;
AnswerRequest.Width=REQUESTERWIDTH;
AnswerRequest.Height=REQUESTERHEIGHT;
AnswerRequest.RelLeft=0;
AnswerRequest.RelTop=0;
AnswerRequest.ReqGadget=&StringBox;
AnswerRequest.ReqBorder=&RequesterBorder;
AnswerRequest.ReqText=&RequestTxt;
AnswerRequest.Flags=0;
AnswerRequest.BackFill=3;
AnswerRequest.ReqLayer=NULL;
AnswerRequest.ImageBMap=NULL;
AnswerRequest.RWindow = w;
GadgetTxt.IText=GadgetString;
GadgetBorder.XY=GadgetPairs;
StringStuff.Buffer=Previous;
StringStuff.UndoBuffer=Previous;
StringBox.GadgetRender=(APTR)&GadgetBorder;
StringBox.GadgetText=&GadgetTxt;
StringBox.SpecialInfo=(APTR)&StringStuff;
RequesterBorder.XY=RequesterPairs;
Request(&AnswerRequest,w);
OnGadget(&StringBox,w,&AnswerRequest);
RefreshGadgets(&StringBox,w,&AnswerRequest);
while (Waiton) {
if(w->UserPort->mp_SigBit) {
message=(struct IntuiMessage *)GetMsg(w->UserPort);
if(message != NULL) {
classb=message->Class;
ReplyMsg((struct Message *)message);
switch (classb) {
case GADGETUP:
EndRequest(&AnswerRequest,w);
Waiton=FALSE;
break;
}
}
}
}
return Previous;
}
const char OKString[4]="OK";
const struct IntuiText OKTxt={1,2,JAM2,14,1,NULL,OKString,NULL};
const static SHORT OKPairs[]={0,0,41,0,41,12,0,12,0,0};
struct Border OKBorder={-1,-1,1,0,JAM1,5,OKPairs,NULL};
struct Gadget OKGadget = {
NULL, /* next gadget */
250,30,41,12, /*left , top, wide, high*/
GADGHCOMP,RELVERIFY|ENDGADGET,
BOOLGADGET|REQGADGET,
(APTR)&OKBorder,NULL,&OKTxt,0L,NULL,2,NULL};
struct PropInfo SliderInfo={ /*Flags*/AUTOKNOB|FREEHORIZ,
0x8000 /*HorizPot %*/,0x8000 /*VertPot*/,
/*HorizBody*/ 0x100 ,/* VertBody*/ 0x0,
0 /*CWidth*/,0 /*CHeight*/,0 /*HpotRes*/,0 /*VPotRes*/,
0 /*LeftBorder*/,0 /*TopBorder*/
};
const SHORT SliderPairs[]={0,0,GADGETWIDTH,0,GADGETWIDTH,GADGETHEIGHT,0,
GADGETHEIGHT,0,0};
const struct Border SliderBorder=
{LEFTEDGE,TOPEDGE,1,2,JAM1,5,SliderPairs,NULL};
struct Gadget SliderGadget = {
&OKGadget,
23,20,GADGETWIDTH,8, /* left,top,wide,high*/
GADGHCOMP,RELVERIFY|GADGIMMEDIATE,
PROPGADGET|REQGADGET,
(APTR)&SliderBorder,NULL,NULL,0L,
(APTR)&SliderInfo,1,NULL};
/*REQUESTER*/
struct IntuiText RemindTxt={1,2,JAM2,5,30,NULL,NULL,NULL};
const UBYTE TitleString[32]="Phase in Radians";
const struct IntuiText TitleTxt={1,2,JAM2,
10 /*left */,1 /*top*/,NULL,TitleString,&RemindTxt};
const char PhaseString[]="-pi -pi/2 0 pi/2 pi";
struct IntuiText PhaseTxt={1,2,JAM2,25,11 /*text down*/,NULL,
PhaseString,&TitleTxt};
SHORT RequesterPairs[]={0,0,REQUESTERWIDTH-1,0,
REQUESTERWIDTH-1,REQUESTERHEIGHT-1,0,REQUESTERHEIGHT-1,0,0};
struct Border RequesterBorder={0,0,1,0,JAM1,5,NULL,NULL};
double GetPhaseInput(double Previous, char TypeString[]) {
struct IntuiMessage *message;
double Answer;
USHORT GadgetNum;
struct Gadget *TempPtr;
register int classb;
struct Requester PhaseRequest;
BOOL Waiton=TRUE;
InitRequester(&PhaseRequest);
PhaseRequest.OlderRequest=NULL;
PhaseRequest.LeftEdge=10; /*position*/
PhaseRequest.TopEdge=30;
PhaseRequest.Width=REQUESTERWIDTH;
PhaseRequest.Height=REQUESTERHEIGHT;
PhaseRequest.RelLeft=0;
PhaseRequest.RelTop=0;
PhaseRequest.ReqGadget=&SliderGadget;
PhaseRequest.ReqBorder=&RequesterBorder;
PhaseRequest.ReqText=&PhaseTxt;
PhaseRequest.Flags=0;
PhaseRequest.BackFill=3;
PhaseRequest.ReqLayer=NULL;
PhaseRequest.ImageBMap=NULL;
PhaseRequest.RWindow = w;
RequesterBorder.XY=RequesterPairs;
RemindTxt.IText=TypeString;
if (fabs(Previous) > 3.141593) {
Previous=(Previous/(fabs(Previous)))*(fabs(Previous)-3.141593);
}
SliderInfo.HorizPot=
(short)(int)((double)10430*Previous+(double)0x8000);
Request(&PhaseRequest,w);
OnGadget(&SliderGadget,w,&PhaseRequest);
RefreshGadgets(&SliderGadget,w,&PhaseRequest);
while (Waiton) {
if(w->UserPort->mp_SigBit) {
message=(struct IntuiMessage *)GetMsg(w->UserPort);
if(message != NULL) {
classb=message->Class;
TempPtr=(struct Gadget *)message->IAddress;
ReplyMsg((struct Message *)message);
if (classb == GADGETUP) {
GadgetNum=TempPtr->GadgetID;
}
if (GadgetNum == 2) {
switch (classb) {
case GADGETUP:
EndRequest(&PhaseRequest,w);
Waiton=FALSE;
Answer=
((95.9E-6)*(double)(SliderInfo.HorizPot))-3.141593;
break;
}
}
}
}
}
return Answer;
}
int GetStringInput(char Previous[],
char RemindString[],
char PromptString[]) {
int failure=0;
USHORT GadgetNum;
struct Gadget *TempPtr;
char OKString[4]="OK";
struct IntuiText OKTxt={1,2,JAM2,14,1,NULL,NULL,NULL};
static SHORT OKPairs[]={0,0,41,0,41,12,0,12,0,0};
struct Border OKBorder={-1,-1,1,0,JAM1,5,NULL,NULL};
struct Gadget OKGadget = {
NULL, /* next gadget */
250,32,41,12, /*left , top, wide, high*/
GADGHCOMP,RELVERIFY|ENDGADGET,
BOOLGADGET|REQGADGET,
NULL,NULL,NULL,0L,NULL,1,NULL};
char QuitString[8]="Quit";
struct IntuiText QuitTxt={1,2,JAM2,4,1,NULL,NULL,NULL};
struct Gadget QuitGadget = {
NULL, /* next gadget */
190,32,41,12, /*left , top, wide, high*/
GADGHCOMP,RELVERIFY|ENDGADGET,
BOOLGADGET|REQGADGET,
NULL,NULL,NULL,0L,NULL,2,NULL};
register int classb;
static char GadgetString[32];
static struct IntuiText GadgetTxt=
{1,2,JAM2,10,GADGETTEXTDOWN,NULL,NULL,NULL};
static struct StringInfo
StringStuff={NULL,NULL,0,STRINGSIZE,0,0,0,0,
CLEFT,CTOP,NULL,0,NULL};
static SHORT GadgetPairs[]=
{0,0,GADGETWIDTH,0,GADGETWIDTH,GADGETHEIGHT,0,
GADGETHEIGHT,0,0};
static struct Border GadgetBorder=
{LEFTEDGE,TOPEDGE,1,2,JAM1,5,NULL,NULL};
static struct Gadget StringBox = {
NULL,2,6,GADGETWIDTH,GADGETHEIGHT,
GADGHCOMP,RELVERIFY|STRINGCENTER,
STRGADGET|REQGADGET,
NULL,NULL,NULL,0L,NULL,1,NULL};
/*REQUESTER*/
static UBYTE RequestString[32];
static struct IntuiText RequestTxt={1,2,JAM2,10,REQUESTERTEXTDOWN,
NULL,RequestString,NULL};
static SHORT RequesterPairs[]={0,0,REQUESTERWIDTH-1,0,
REQUESTERWIDTH-1,REQUESTERHEIGHT-1+25,0,REQUESTERHEIGHT-1+25,0,0};
static struct Border RequesterBorder={0,0,1,0,JAM1,5,NULL,NULL};
struct Requester AnswerRequest;
struct IntuiMessage *message;
BOOL Waiton=TRUE;
InitRequester(&AnswerRequest);
OKGadget.NextGadget=&QuitGadget;
OKBorder.XY=OKPairs;
OKGadget.GadgetRender=(APTR)&OKBorder;
OKGadget.GadgetText=&OKTxt;
QuitGadget.GadgetRender=(APTR)&OKBorder;
QuitTxt.IText=QuitString;
QuitGadget.GadgetText=&QuitTxt;
OKTxt.IText=OKString;
StringBox.NextGadget=&OKGadget;
strcpy(RequestString,RemindString);
strcpy(GadgetString,PromptString);
AnswerRequest.OlderRequest=NULL;
AnswerRequest.LeftEdge=10; /*position*/
AnswerRequest.TopEdge=30;
AnswerRequest.Width=REQUESTERWIDTH;
AnswerRequest.Height=REQUESTERHEIGHT;
AnswerRequest.RelLeft=0;
AnswerRequest.RelTop=0;
AnswerRequest.ReqGadget=&StringBox;
AnswerRequest.ReqBorder=&RequesterBorder;
AnswerRequest.ReqText=&RequestTxt;
AnswerRequest.Flags=0;
AnswerRequest.BackFill=3;
AnswerRequest.ReqLayer=NULL;
AnswerRequest.ImageBMap=NULL;
AnswerRequest.RWindow = w;
GadgetTxt.IText=GadgetString;
GadgetBorder.XY=GadgetPairs;
StringStuff.Buffer=Previous;
StringStuff.UndoBuffer=Previous;
StringBox.GadgetRender=(APTR)&GadgetBorder;
StringBox.GadgetText=&GadgetTxt;
StringBox.SpecialInfo=(APTR)&StringStuff;
RequesterBorder.XY=RequesterPairs;
Request(&AnswerRequest,w);
OnGadget(&StringBox,w,&AnswerRequest);
RefreshGadgets(&StringBox,w,&AnswerRequest);
while (Waiton) {
if(w->UserPort->mp_SigBit) {
message=(struct IntuiMessage *)GetMsg(w->UserPort);
if(message != NULL) {
classb=message->Class;
TempPtr=(struct Gadget *)message->IAddress;
ReplyMsg((struct Message *)message);
if(classb == GADGETUP) {
GadgetNum=TempPtr->GadgetID;
switch(GadgetNum) {
case 0: /*got string*/
failure=0;
break;
case 1: /*string OK*/
failure=0;
break;
case 2: /*quit*/
failure=1;
break;
}
EndRequest(&AnswerRequest,w);
Waiton=FALSE;
break;
}
}
}
}
return failure;
}
#include "AlgoRhythms.h"
int GetChannelStuff(struct NoteEvent *Event, int Number) {
/* TempWalking is int */
/* ->Walking is int*/
/* Gadget.Flags is USHORT*/
int TempHigh,TempLow,TempChannel,TempWalking;
char OKString[4]="OK"; /* L T txt next*/
struct IntuiText OKTxt={1,2,JAM2,24,1,NULL,NULL,NULL};
static SHORT OKPairs[]={0,0,61,0,61,12,0,12,0,0};
/* XY */
struct Border OKBorder={-1,-1,1,0,JAM1,5,NULL,NULL};
struct Gadget OKGadget = {NULL, /* next gadget */
185,67,61,12, /*left , top, wide, high*/
GADGHCOMP,RELVERIFY|ENDGADGET,BOOLGADGET|REQGADGET,
NULL,NULL,NULL,0L,NULL,1,NULL};
char CancelString[8]="Cancel";
struct IntuiText CancelTxt={1,2,JAM2,4,1,NULL,NULL,NULL};
struct Gadget CancelGadget = {NULL, /* next gadget */
5,67,61,12, /*left , top, wide, high*/
GADGHCOMP,RELVERIFY|ENDGADGET,BOOLGADGET|REQGADGET,
NULL,NULL,NULL,0L,NULL,2,NULL};
static UBYTE HighString[16]="High Note";
static struct IntuiText HighTxt={1,2,JAM2,1,-8,NULL,NULL,NULL};
static char HighBuff[80];
static struct StringInfo HighInfo={NULL,NULL,0,STRINGSIZE,0,0,0,0,
LEFT,TOP,NULL,0,NULL};
static USHORT HighPairs[10]={0,0,GADGETWIDE,0,
GADGETWIDE,8,0,8,0,0};
static struct Border HighBorder=
{LEFTEDGE,TOPEDGE,1,2,JAM1,5,NULL,NULL};
static struct Gadget HighGadg = {NULL,2,8,GADGETWIDE,GADGETHIGH,
GADGHCOMP,RELVERIFY|STRINGCENTER,STRGADGET|REQGADGET,
NULL,NULL,NULL,0L,NULL,3,NULL};
static UBYTE LowString[16]="Low Note";
static struct IntuiText LowTxt={1,2,JAM2,1,-8,NULL,NULL,NULL};
static char LowBuff[80];
static struct StringInfo LowInfo={NULL,NULL,0,STRINGSIZE,0,0,0,0,
LEFT,TOP,NULL,0,NULL};
static struct Gadget LowGadg = {NULL,2,24,GADGETWIDE,GADGETHIGH,
GADGHCOMP,RELVERIFY|STRINGCENTER,STRGADGET|REQGADGET,
NULL,NULL,NULL,0L,NULL,4,NULL};
static UBYTE ChannelString[16]="Channel";
static struct IntuiText ChannelTxt=
{1,2,JAM2,1,-8,NULL,NULL,NULL};
static char ChannelBuff[80];
static struct StringInfo
ChannelInfo={NULL,NULL,0,STRINGSIZE,0,0,0,0,
LEFT,TOP,NULL,0,NULL};
static struct Gadget ChannelGadg = {NULL,2,40,GADGETWIDE,GADGETHIGH,
GADGHCOMP,RELVERIFY|STRINGCENTER,
LONGINT|STRGADGET|REQGADGET,NULL,NULL,NULL,0L,NULL,5,NULL};
static UBYTE WalkString[16]="Walk";
static struct IntuiText WalkTxt=
{1,2,JAM2,15,1,NULL,NULL,NULL};
static struct Gadget WalkGadg = {NULL,95,67,61,12,
GADGHCOMP,TOGGLESELECT|RELVERIFY,
BOOLGADGET|REQGADGET,NULL,NULL,NULL,0L,NULL,6,NULL};
/*REQUESTER*/
static UBYTE RequestString[48];
static struct IntuiText RequestTxt={1,2,JAM2,55,50,
NULL,RequestString,NULL};
static SHORT RequesterPairs[]={0,0,249,0,249,79,0,79,0,0};
static struct Border RequesterBorder={0,0,1,0,JAM1,5,NULL,NULL};
struct Requester AnswerRequest;
struct IntuiMessage *message;
register int classb;
int failure=0;
USHORT GadgetNum;
struct Gadget *TempPtr;
BOOL Waiton=TRUE;
sprintf(RequestString,"%s %2d","Setup Channel",Number);
TempHigh=Event->HighPitch;
TempLow=Event->LowPitch;
TempWalking=Event->Walking;
TempChannel=Event->Channel;
InitRequester(&AnswerRequest);
/*NEW*/
if(Event->Walking) {
WalkGadg.Flags |= SELECTED;
}
else
{
WalkGadg.Flags &= ~(SELECTED);
}
OKGadget.NextGadget = NULL;
CancelGadget.NextGadget=&OKGadget;
HighGadg.NextGadget=&CancelGadget;
LowGadg.NextGadget=&HighGadg;
ChannelGadg.NextGadget=&LowGadg;
WalkGadg.NextGadget=&ChannelGadg;
/*NEW STRINGS*/
OKTxt.IText=OKString;
CancelTxt.IText=CancelString;
HighTxt.IText=HighString;
LowTxt.IText=LowString;
ChannelTxt.IText=ChannelString;
WalkTxt.IText=WalkString;
/*NEW PAIRS*/
OKBorder.XY=OKPairs;
HighBorder.XY=HighPairs;
/*NEW Borders*/
OKGadget.GadgetRender = (APTR)&OKBorder;
CancelGadget.GadgetRender = (APTR)&OKBorder;
HighGadg.GadgetRender = (APTR)&HighBorder;
LowGadg.GadgetRender = (APTR)&HighBorder;
WalkGadg.GadgetRender = (APTR)&OKBorder;
/*New txts*/
OKGadget.GadgetText=&OKTxt;
CancelGadget.GadgetText=&CancelTxt;
HighGadg.GadgetText=&HighTxt;
LowGadg.GadgetText=&LowTxt;
ChannelGadg.GadgetText=&ChannelTxt;
WalkGadg.GadgetText=&WalkTxt;
/*NEW INFO*/
HighGadg.SpecialInfo=(APTR)&HighInfo;
LowGadg.SpecialInfo=(APTR)&LowInfo;
ChannelGadg.SpecialInfo=(APTR)&ChannelInfo;
/*New BUFFS*/
HighInfo.Buffer=HighBuff;
LowInfo.Buffer=LowBuff;
ChannelInfo.Buffer=ChannelBuff;
AnswerRequest.OlderRequest=NULL;
AnswerRequest.LeftEdge=4; /*position*/
AnswerRequest.TopEdge=3;
AnswerRequest.Width=250;
AnswerRequest.Height=80;
AnswerRequest.RelLeft=0;
AnswerRequest.RelTop=0;
AnswerRequest.ReqGadget=&WalkGadg;
AnswerRequest.ReqBorder=&RequesterBorder;
AnswerRequest.ReqText=&RequestTxt;
AnswerRequest.Flags=0;
AnswerRequest.BackFill=3;
AnswerRequest.ReqLayer=NULL;
AnswerRequest.ImageBMap=NULL;
AnswerRequest.RWindow = w;
RequesterBorder.XY=RequesterPairs;
sprintf(ChannelBuff,"%2d",Event->Channel);
MIDItoPitchName(Event->HighPitch,HighBuff);
MIDItoPitchName(Event->LowPitch,LowBuff);
Request(&AnswerRequest,w);
OnGadget(&WalkGadg,w,&AnswerRequest);
RefreshGadgets(&WalkGadg,w,&AnswerRequest);
while (Waiton) {
if(w->UserPort->mp_SigBit) {
message=(struct IntuiMessage *)GetMsg(w->UserPort);
if(message != NULL) {
classb=message->Class;
TempPtr=(struct Gadget *)message->IAddress;
ReplyMsg((struct Message *)message);
if(classb == GADGETUP) {
GadgetNum=TempPtr->GadgetID;
switch(GadgetNum) {
case 1: /*OK*/
failure=0;
if(TempHigh > 0) {
Event->HighPitch=TempHigh;
}
if(TempLow > 0) {
Event->LowPitch =TempLow;
}
Event->Channel=TempChannel;
Event->Walking=TempWalking;
Waiton=FALSE;
break;
case 2: /*Cancel*/
failure=1;
Waiton=FALSE;
break;
case 3: /*HighPitch*/
failure=0;
TempHigh=PitchNametoMIDI(HighBuff);
break;
case 4: /*LowPitch*/
failure=0;
TempLow=PitchNametoMIDI(LowBuff);
break;
case 5: /*Channel*/
failure=0;
TempChannel=atoi(ChannelBuff);
break;
case 6: /*Walking*/
failure=0;
TempWalking =
((WalkGadg.Flags & SELECTED) != 0);
break;
}
}
}
}
}
EndRequest(&AnswerRequest,w);
return failure;
}
char *MIDItoPitchName(int NoteNum, char *PitchName)
{
const char NoteNames[12][4]={"C","C#","D","D#","E","F","F#","G",
"G#","A","A#","B"};
sprintf(PitchName,"%s%1d",NoteNames[NoteNum % 12],(NoteNum/12)-1);
return PitchName;
}
int PitchNametoMIDI(char *PitchName)
{
char TempString[4]={0,0,0,0};
int PitchMIDI;
const int SmallScale[7]={9,11,0,2,4,5,7};
if((toupper(PitchName[0]) > 64) && (toupper(PitchName[0])<72))
{
PitchMIDI = SmallScale[toupper(PitchName[0])-65];
}
else { return 0; }
if((strlen(PitchName) < 2) || (strlen(PitchName) >3)) return 0;
if (strlen(PitchName) == 3)
{
switch (PitchName[1]) {
case 'b':
PitchMIDI = PitchMIDI-1;
break;
case 'B':
PitchMIDI = PitchMIDI-1;
break;
case '#':
PitchMIDI = PitchMIDI + 1;
break;
}
}
TempString[0]=PitchName[strlen(PitchName)-1];
PitchMIDI=PitchMIDI+(12*(atoi(TempString)+1));
return PitchMIDI;
}